  	//不同的成绩板块的显示按钮
	$(function(){
		var id = 0;

		//设置body的背景
		$("body").css("height","100vh");

		$("body").css("background"," white url(https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1543061193115&di=82d70926553c2a7fe18482a2bcab540f&imgtype=0&src=http%3A%2F%2Fwww.deyu.ln.cn%2Fimages%2Fobuwgmjoo5uw4nbqgayc4y3pnu%2Fmobile%2F2%2F5385840e12819.jpg) no-repeat").css("background-size","100% 100%");


		$(".grade-top").click(function(){
			$(".grade-show-part").eq(0).show().siblings().hide();
		});

		$(".grade-academy-top").click(function(){
			$(".grade-show-part").eq(1).show().siblings().hide();
		});


		//页面加载完成是加载个人成绩和前一部分的全部学生排名
		/*
			从URL中获取数据
			name grade academy time rank
		*/
		function setMessage(){
			var para = window.location.search;
			id = para.split("=")[1];
			getRank(30);
		}
		setMessage(); 

		/*
			页面加载完成时加载
				上传获取的最大数据量
				返回学生数据信息
		*/

				function getRank(end){
					$.ajax({
						type:"GET",
						dataType:"json",
						url:"QuestionServlet?method=giveRank",
						data:{
							length:end,
							studentId:id
						},
						success:function(data){
							console.log(data);
							var result = data;
							for(var  i = result.length-2;i>=0;i--){
								var index  ={index:result.length-i-1};
								var _result = template("template-all",$.extend({},result[i],index));
								console.log(_result);
								$(".academy-all-tbody").append(_result);
							}
							//显示学生的数据
							var temp = template("template_grade",result[result.length-1]);
							$("#my_message").append(temp);
							//根据剩余多少条数据设置按钮的实现
							if(_result.length==30){
								$("#getMore").show();
							}else{
								$("#getMore").hide();
							}
						}
					});
				}



		//根据数量决定加载更多按钮是否显示
		//先获取最多30条
		
		
		
		
		//加载更多按钮
		$("#getMore").click(function(){
			if($(".student-message").length==30){
				getRank(70);
			}
		});




		//院系板块点击时的事件
		$(".grade-academy-top").click(function(){
			//加载院系的信息
			console.log("load academy message");
			var length = $(".academy-message").length;
			if(length==0){
				console.log(" start load academy message");
				$.ajax({
					type:"GET",
					dataType:"json",
					url:"QuestionServlet?method=getAcademyRank",
					success:function(data){
						var result = data;
						//整合数据
						for(var i = 0;i<result.length;i++){
							var per =  result[i]["joinPersons"];
							var pers =  parseInt(result[i]["totalPersons"]);
							var nums =  parseInt(result[i]["totalScore"]);
							var join = 0;
							var aver = 0;
							if(per!=0&&pers!=0){
								join = per/pers;
								aver = nums/per;
							}

							
							var message =  {join:join.toFixed(6),aver:aver.toFixed(2)};
							data[i] = $.extend({},result[i],message);
							var index = {index:i+1};
							var temp  = template("template-academy",$.extend({},result[i],index));
							console.log(temp);
							$(".academy-message-tbody").append(temp);
						}
					}
				});
			}
		});

	});